<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查询设备详细信息示例</title>
    <style>
        .equipmentList > button {
            margin-top: 10px;
        }
    </style>
    <script src="./witcloud-sdk-1.0.0.min.js"></script>
</head>
<body>
    <div class="equipmentList">
        <div id="onlineStatus">在线状态：</div>
        <div id="lastOnlineTime">最后在线时间：</div>
        <div id="deviceNo">设备号：</div>
        <div id="type">设备类型：</div>
        <div id="dataStorage">数据存储数量：</div>
        <div id="labels">设备标签：</div>
        <div id="projectId">设备项目：</div>
        <div id="status">设备状态：</div>
        <button onclick="detail()"> 查询设备详细 </button>
    </div>

    <script>
        // 注意：在查询之前需要进行登录操作
        // 查询方法：点击后向后台服务器发起查询设备请求
        function detail() {
            var param = {};
            param.id = '1551489042042724353' // 例如：您的设备id

            witCloudApi.equipmentApi.detail(param).then((res) => {
                if (res.success) {
                    // alert('查询成功')
                    document.getElementById("onlineStatus").textContent = "在线状态：" + res.data.onlineStatus
                    document.getElementById("lastOnlineTime").textContent = "最后在线时间：" + res.data.lastOnlineTime
                    document.getElementById("deviceNo").textContent = "设备号：" + res.data.no
                    document.getElementById("type").textContent = "设备类型：" + res.data.type
                    document.getElementById("dataStorage").textContent = "数据存储数量：" + res.data.currentDataStorage + "/" + res.data.maxDataStorage
                    document.getElementById("labels").textContent = "设备标签：" + res.data.labels
                    document.getElementById("projectId").textContent = "设备项目：" + res.data.projectId
                    document.getElementById("status").textContent = "设备状态：" + res.data.status
                } else {
                    // 如果查询失败请按照 res.message 的返回信息修正错误
                    alert('查询失败：' + res.message)
                }
            }).catch((err) => {
                alert('查询错误：' + err.message)
            })
        }
    </script>
</body>

</html>